package group;

import java.util.ArrayList;
import java.util.Random;

import student.Student;

/*
 * ==UML
 * Methoden fertig
 */
/**
 * 
 * @author Gero Kraus
 * 
 */
public class SystemGroup extends Group
{
	private ArrayList<Student> students = new ArrayList<Student>();

	public SystemGroup()
	{
		super("keine Gruppe"); // Systemgruppe braucht keinen Namen
	}

	public void addStudent(String firstName, String lastName, int matrNr,
			String mail, String branch)
	{
		students.add(new Student(firstName, lastName, matrNr, mail, branch));
	}

	public void addStudent(Student student)
	{
		if (student != null)
			students.add(student);
	}

	/**
	 * Gibt einen zufälligen Studenten zurück und löscht ihn aus der
	 * Systemgruppe
	 */
	public Student getStudent()
	{
		Random r = new Random();
		int number = r.nextInt(students.size());
		//System.out.println(students.size());
		Student s = students.get(number);
		students.remove(number);
		return s;
	}

	public boolean removeStudent(Student s)
	{
		return students.remove(s);
	}

	/**
	 * Gibt alle Studenten zurück
	 * 
	 * @return alle Studenten
	 */
	public ArrayList<Student> getMembers()
	{
		return students;
	}

	@Override
	public void setName(String name)
	{
		super.setName(name);
	}

	@Override
	public String getName()
	{
		return super.getName();
	}

}
